﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class SkyFab : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string target = Request.QueryString["target"];
            if(target!=null)
            {
                this.SetAllSideBarPanelCollapse();
                this.SetAllHyperLinkCssClassNull();
                target = target.ToLower();
                Session["target"] = target;
                
            }
            else if (Session["target"]!=null)
            {
                target = Session["target"] as string;
            }
            else
            {
                target = "home";
            }

            switch (target)
            {
                case "home":
                    HomePanel.Visible = true;
                    HomeHyperLink.CssClass = "active";
                    break;
                case "customer":
                    CustomerPanel.Visible = true;
                    CustomerHyperLink.CssClass = "active";
                    break;
                case "vendor":
                    VendorPanel.Visible = true;
                    VendorHyperLink.CssClass = "active";
                    break;
                case "query":
                    QueryPanel.Visible = true;
                    QueryHyperLink.CssClass = "active";
                    break;
                case "product":
                    ProductPanel.Visible = true;
                    ProductHyperLink.CssClass = "active";
                    break;
                case "report":
                    ReportPanel.Visible = true;
                    ReportHyperLink.CssClass = "active";
                    break;
                case "setting":
                    SettingPanel.Visible = true;
                    SettingHyperLink.CssClass = "active";
                    break;
            }

            if (Session["User"] == null)
            {
                //ViewState["retu"] = Request.UrlReferrer.ToString();
                Response.Redirect("Login.aspx",false);
            }
            else
            {
                LoginLinkButton.Visible = false;
            }
        }


        protected void SetAllSideBarPanelCollapse()
        {
            HomePanel.Visible = false;
            CustomerPanel.Visible = false;
            VendorPanel.Visible = false;
            QueryPanel.Visible = false;
            ProductPanel.Visible = false;
            ReportPanel.Visible = false;
            SettingPanel.Visible = false;

        }
        protected void SetAllHyperLinkCssClassNull()
        {
            HomeHyperLink.CssClass = null;
            CustomerHyperLink.CssClass = null;
            VendorHyperLink.CssClass = null;
            QueryHyperLink.CssClass = null;
            ProductHyperLink.CssClass = null;
            ReportHyperLink.CssClass = null;
            SettingHyperLink.CssClass = null;
        }

       protected void LogoutLinkButton_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Response.Redirect("Login.aspx");
        }

       protected void LoginLinkButton_Click(object sender, EventArgs e)
       {

       }
    }
}
